﻿Imports System.Threading
Public Class Frm_Main

    Private Sub btn_avoc_bur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_avoc_bur.Click
        Partager.StandardInitial()
        Frm_Avoc_Bure.MdiParent = Me
        Frm_Avoc_Bure.Show()

        'For Each fr As Form In Application.OpenForms
        '    If fr.Name <> "Frm_Main" Then
        '        fr.Close()
        '    End If
        '    Application.OpenForms.Item(0).Close()
        'Next
    End Sub

    Private Sub btn_clients_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_clients.Click
        Partager.StandardInitial()
        'tarik
        Partager.verifPriv(Frm_Clients)
        'end tarik
    End Sub

    Private Sub btn_adver_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_adver.Click
        Partager.StandardInitial()
        'tarik
        Partager.verifPriv(Frm_Adver)
        'end tarik
    End Sub

    Private Sub btn_avoc_adv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_avoc_adv.Click
        Partager.StandardInitial()
        'tarik
        Partager.verifPriv(Frm_Avoc_Adv)
        'end tarik

    End Sub


    Private Sub btn_temoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_temoi.Click
        Partager.StandardInitial()
        'tarik
        Partager.verifPriv(Frm_chohoud)
        'end tarik

    End Sub



    Private Sub Btn_Avoc_Clien_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Avoc_Clien.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Avoc_Clien)
    End Sub

    Private Sub ButtonItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Avoc_mokhabara.Click
        Partager.StandardInitial()

        Partager.verifPriv(Frm_Avoc_mokhabara)
    End Sub

    Private Sub ButtonItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem2.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Dossier)
    End Sub
    Private Sub ButtonItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem11.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_khabir)
    End Sub

    Private Sub ButtonItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem12.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Massarif_khibra)
    End Sub

    Private Sub ButtonItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem13.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_at3ab)
    End Sub

    Private Sub ButtonItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem14.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_sahib_maktab)
    End Sub

    Private Sub ButtonItem15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem15.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_mowadafin)
    End Sub

    Private Sub ButtonItem18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem18.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_jalassat)
    End Sub

    Private Sub ButtonItem22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem22.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_dalil)
    End Sub

    Private Sub ButtonItem23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem23.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_mawa3id)
    End Sub

    Private Sub ButtonItem20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem20.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Rechercher)
    End Sub

    Private Sub ButtonItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem4.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Idafa_Mowakilin)
    End Sub



    Private Sub ButtonItem8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem8.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Dossier_Orig)
    End Sub

    Private Sub ButtonItem9_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem9.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_massarif)
    End Sub

    Private Sub ButtonItem19_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem19.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Archive)
    End Sub

    Private Sub ButtonItem6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem6.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Papier)
    End Sub

    Private Sub ButtonItem5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem5.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_a7kam)
    End Sub

    Private Sub ButtonItem21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

   

    Private Sub ButtonItem27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem27.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Recensement)
    End Sub

   

   

    Private Sub ButtonItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem10.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_khibra)
    End Sub

    Private Sub ButtonItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem3.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_ijra2at)
    End Sub

    Private Sub ButtonItem17_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem17.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Idafa_Chohoud)
    End Sub

    Private Sub ButtonItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem7.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_mo9arir)
    End Sub

    Private Sub ButtonItem30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem30.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_idafat_9da2i)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'For Each frm As Form In Application.OpenForms
        '    If frm.Name <> Me.Name Then

        '        Partager.open()
        '        Dim cmd As New SqlClient.SqlCommand("insert into Form values('" & frm.Name & "','" & frm.Text & "','')", Partager.con)
        '        cmd.ExecuteNonQuery()

        '    End If
        'Next
    End Sub

    Private Sub ButtonItem24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem24.Click

        If "mazal" = "masalina" Then
            Partager.StandardInitial()
            If Partager.moi.type = True Then
                Frm_sala7iyat.MdiParent = Me
                Frm_sala7iyat.Show()
            Else
                MsgBox("ليست لديك الصلاحية للدخول لهذه النافذة", MsgBoxStyle.Critical, "خطأ")
            End If
        Else
            MsgBox("^_^ عفوا، لا يمكنك الدخول لهذه الخاصية لأنها قيد الإنجاز ", MsgBoxStyle.Information, "قيد الإنجاز")
        End If
    End Sub

    Private Sub ButtonItem31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem31.Click
        If "mazal" = "masalina" Then
            Partager.StandardInitial()
            If Partager.Administrat.login <> "" And Partager.Administrat.pass <> "" Then
                AdminForm.MdiParent = Me
                AdminForm.Show()
            Else
                MsgBox("ليست لديك الصلاحية للدخول لهذه النافذة", MsgBoxStyle.Critical, "خطأ")
            End If
        Else
            MsgBox("^_^ عفوا، لا يمكنك الدخول لهذه الخاصية لأنها قيد الإنجاز ", MsgBoxStyle.Information, "قيد الإنجاز")
        End If
    End Sub

    Private Sub ButtonItem32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem32.Click
        'Partager.StandardInitial()
        'Partager.verifPriv(Frm_Registre)

        Frm_Registre.MdiParent = Me
        Frm_Registre.Show()
    End Sub

    Private Sub ButtonItem25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem25.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_baseDonne)
    End Sub

    Private Sub Frm_Main_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        My.Computer.Audio.Stop()
        Dim cou As Integer = Application.OpenForms.Count - 1
        Dim i As Integer = 0
        While i <= cou
            If Application.OpenForms.Item(i).Name <> "Frm_Main" And Application.OpenForms.Item(i).Name <> "Frm_Login" Then
                Application.OpenForms.Item(i).Close()

                cou -= 1
                i -= 1
            End If
            i += 1
        End While


        If Partager.moi.passe <> "" And Partager.Administrat.pass = "" Then
            Try
                Dim reg As New Registre(1, 1, Partager.DateEntrer, DateTime.Now)
                Partager.moi.Ajouter_registre(reg)
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation)
                Partager.close()
            End Try
        End If

        Frm_Login.isHidden = False
        Frm_Login.Show()

    End Sub

    Private Sub ButtonItem21_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem21.Click
        Partager.StandardInitial()
        Partager.verifPriv(frmRapportControle)
    End Sub

    Private Sub ButtonItem33_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem33.Click
        Me.Close()
        Partager.StandardInitial()
    End Sub

    Private Sub Frm_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Timer1.Start()
        If Partager.moi.passe <> "" Then
            Partager.DateEntrer = DateTime.Now
        End If

        'Remplir la liste des décisions tardés

        Dim isSegmentaire As Boolean
        Dim isModawala As Boolean = False
        Dim max As ijraa
        Partager.lstDecTarde = New ArrayList

        Partager.moi.remplir_List_info_fichier()

        For Each ds As Dossier In Partager.moi.List_info_fichier
            isSegmentaire = False

            If ds.Archive = False Then
                ds.remplir_List_decisions()
                ds.remplir_List_ijraa()

                If Not ds.List_decisions Is Nothing Then
                    For Each desc As decisions In ds.List_decisions
                        If desc.Type = "قطعي" Then
                            isSegmentaire = True
                            Exit For
                        End If
                    Next
                End If

                If Not ds.List_ijraa Is Nothing Then
                    If ds.List_ijraa.Count > 0 Then
                        max = CType(ds.List_ijraa(0), ijraa)
                        If Not isSegmentaire Then
                            For Each tran As ijraa In ds.List_ijraa
                                If tran.Date_ijraa > max.Date_ijraa Then
                                    max = tran
                                End If
                            Next
                            If max.Date_ijraa < Now Then
                                max.Id_Dossier = ds.id
                                Partager.lstDecTarde.Add(max)
                            End If
                        End If
                    End If
                End If
            End If
        Next

    End Sub
    Private Sub ButtonItem34_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem34.Click
        Partager.StandardInitial()
        Partager.verifPriv(frmAlarmes)
    End Sub

    Private Sub ButtonItem35_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem35.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_Plainte)
    End Sub

    Private Sub ButtonItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem16.Click
        Partager.StandardInitial()
        Partager.verifPriv(frmProces)
    End Sub


    Private Sub ButtonItem37_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem37.Click
        Partager.StandardInitial()
        Partager.verifPriv(Frm_a7kame)
    End Sub
End Class